<?php
	//require_once(CORE_DIR.'/admin/controller/goods/ctl.product.php');
	//require_once(CORE_INCLUDE_DIR.'/pageFactory');
	$include_dir =  ((!defined('SHOP_DEVELOPER') || !constant('SHOP_DEVELOPER')) && version_compare(PHP_VERSION,'5.0','>=')?'include_v5':'include');
	if(!class_exists('pageFactory')){
		require(CORE_DIR.'/'.$include_dir.'/pageFactory.php');
	}

	class admin_ctl_collocate_goods extends pageFactory
	{
		function admin_ctl_collocate_goods()
		{
			parent::pageFactory();
			$this->system = &$GLOBALS['system'];
			$this->db = &$this->system->database();
		}

		function init()
		{
			if ($_POST['goods']['goods_id'])
			{
				$objGoods = $this->system->loadModel('trading/goods');
				$aCollocation = unserialize($objGoods->getGoodsMemo($_POST['goods']['goods_id'],'collocation'));
				$this->pagedata['showRow'] = empty($aCollocation)?false:true;
				$this->pagedata['goods']['collocation'] = $aCollocation;
				$this->pagedata['collocation']['goods_id'] = $_POST['goods']['goods_id'];
				//error_log(print_r($this->pagedata['goods']['collocation'],true),3,__FILE__.'.'.__FUNCTION__.'.collocation.log');//alone add
			}
			$this->display('view/admin/collocation/collocation.html');
		}

		function showCollocationInfo()
		{
			$this->pagedata['aOptions'] = array('goods'=>__('选择几件作为搭配商品'), 'filter'=>__('选择一组搜索结果作为搭配商品'));
			$this->pagedata['info_goods_id'] = $_REQUEST['goods_id'];
			$this->display('view/admin/collocation/info.html');
			return;
		}

		function doCollocation()
		{
			$this->pagedata['collocation'] =array('name'=>$_POST['name'],'type'=>$_POST['type']);
			$this->pagedata['collocation']['colloparams']['dis_goods'][] = $_POST['info_goods_id'];
			$this->pagedata['key'] = time();
			$this->display('view/admin/collocation/row.html');
		}
	}

?>